1. Field of the Invention
This invention relates to the field of data processing systems. More particularly, this invention relates to the provision of cache hints to an operating system when requesting the operating system to make a file access.
2. Description of the Prior Art
It is known for the various versions of the Windows operating system produced by Microsoft Corporation to provide file caching functionality. This functionality broadly speaking is that when a file access to disk is made then more than the immediatley required data may be read from the disk and stored within the random access memory of the system on the assumption that it will subsequently be required. This caching strategy has the advantage that should a subsequent access to cache data occur then that access can be serviced more rapidly from memory than would be the case from disk and the time spent initially setting up the first access to the data held on the disk does not have to be repeated.
In order to assist this cache functionality to perform in an improved fashion, it is known to provide a xe2x80x9ccaching hintxe2x80x9d when an application opens a file. The caching hint is an indication to the operating system of how the application intends to use the file and the operating system can respond by performing caching and allocated cache resources in a way that suits the intended use and the existing state of the system. Within the Windows operating system the four types of caching hint currently supported are:
sequential access (the file is intended to be read sequentially);
random access (the file is intended to be read randomly);
no caching (the operating system should not use any caching); and
no hint (the operating system should itself decide the best caching strategy).
Known application programs that exploit this functionality, such as the McAfee virus scanner engine hard code the cache hint to be used. In the case of the McAfee virus scanner engine this always uses sequential cache hints.
Measures that can improve system performance are strongly advantageous.
Viewed from one aspect the present invention provides a computer program product comprising a computer program operable to control a computer to access a computer file, said computer program comprising:
(i) file characterising logic operable to detect at least one characteristic of said computer file;
(ii) cache hint selecting logic operable in dependence upon said at least one characteristic to select from among a plurality of different possible cache hints a selected cache hint to use in association with said access to said computer file; and
(iii) file access request issuing logic operable to issue to an operating system a file access request for said computer file accompanied by said selected cache hint.
The invention recognises that hard coding a particular caching hint into a program is often sub-optimal. In particular, a cache hint that may be appropriate to a file access of a certain type of file of a certain size may not be appropriate to a file having different characteristics. Hard coding specific cache hints for every possible individual file access is also not practical in many situations where the files to be accessed cannot be predicted in advance. An example of such a situation is a computer virus scanner where the files to be scanned for computer viruses can have any file name and widely varying file characteristics. In order to address these problems the invention takes an active approach to cache hint determination and detects one or more characteristics of the file to be accessed and then selects the cache hint to be used independence upon that detected characteristic. This avoids hard coding a single cache hint for all file accesses so enabling them to be better matched to the particular circumstances and yet avoids the open ended task of trying to store an individual cache hint for every possible computer file to be accessed.
Whilst the cache hint selecting logic could be static and predefined, in preferred embodiments of the invention it is responsive to hint defining data that is adapted in use in dependence upon measured file access performance. Making the cache hint selection adaptive in this way enables it to be more accurately matched to the particular configuration and performance of the system on which it is operating and possibly also to track changes in that system that affect the performance.
The hint defining data may be arranged in many different ways, but a particularly suitable arrangement is one in which the hint defining data for each possible combination of one or more characteristics of the computer file provides data measuring the file access performance for each of the possible different cache file hints. A selection can then be made based upon which cache file hint is measured to give the best performance.
In order to avoid false measurements being made that could adversely affect the accuracy of the selected cache hint, preferred embodiments of the invention only update the hint defining data for files that are determined not already to be cached as already cached files could distort the measurements.
In order to allow the system to perform at a higher performance level from the outset preferred embodiments initialise the hint defining data based upon configuration characteristics of the computer upon which the file access request is to be made. The characteristics used for this initialisation selection may be the operating system type and the installed memory size.
Viewed from other aspects the invention also provides a method for accessing a computer file and an apparatus for accessing a computer file.
The above, and other objects, features and advantages of this invention will be apparent from the following detailed description of illustrative embodiments which is to be read in connection with the accompanying drawings.